package graph.day01;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Kama_98 {

    static int[][] graph;
    static LinkedList<Integer> path = new LinkedList<>();
    static List<List<Integer>> res = new ArrayList<>();

    private static void dfs(int cur, int des) {
        if (cur == des) {
            res.add(new LinkedList<>(path));
            return;
        }
        for (int i = 1; i < graph[cur].length; i++) {
            if (graph[cur][i] == 1) {
                path.addLast(i);
                dfs(i, des);
                path.removeLast();
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        graph = new int[n + 1][n + 1];
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            graph[start][end] = 1;
        }
        path.addLast(1);
        dfs(1, n);
        if (res.isEmpty()) System.out.println(-1);
        for (List<Integer> path : res) {
            for (int i = 0; i < path.size(); i++) {
                if (i == path.size() - 1) {
                    System.out.print(path.get(i));
                    System.out.println();
                    break;
                }
                System.out.print(path.get(i) + " ");
            }
        }
    }
}
